package org.threadCase7;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.FutureTask;

public class Demo {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        callAbleDemo call1=new callAbleDemo();
        callAbleDemo call2=new callAbleDemo();
        FutureTask<Integer> f1=new FutureTask(call1);
        FutureTask<Integer> f2=new FutureTask(call2);
        Thread t1=new Thread(f1);
        Thread t2=new Thread(f2);
        t1.setName("抽奖箱1");
        t2.setName("抽奖箱2");
        t1.start();
        t2.start();
        Integer max1 = f1.get();
        Integer max2 = f2.get();
        if (max1>max2){
            System.out.println(t1.getName()+"抽到了最大奖项为："+max1+"元");
        }else {
            System.out.println(t2.getName()+"抽到了最大奖项为："+max2+"元");
        }
    }
}
